﻿Public Class reports

 

    Private Sub Btn_total_search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_total_search.Click
        FullSearchvb.Show()
    End Sub

    Private Sub Ch_B_Name_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ch_B_Name.CheckedChanged
  

        If Ch_B_Name.Checked = True Then
            C_B_G.Enabled = True
        Else
            C_B_G.Enabled = False
        End If

        If Ch_B_Name.Checked = True Or Ch_B_Date.Checked = True Then
            Btn_Search.Enabled = True
        Else
            Btn_Search.Enabled = False
        End If
    End Sub

    Private Sub Ch_B_Date_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ch_B_Date.CheckedChanged
        If Ch_B_Date.Checked = True Then
            Date_From.Enabled = True
            Date_To.Enabled = True
        Else
            Date_From.Enabled = False
            Date_To.Enabled = False
        End If

        If Ch_B_Name.Checked = True Or Ch_B_Date.Checked = True Then
            Btn_Search.Enabled = True
        Else
            Btn_Search.Enabled = False
        End If
    End Sub

    Private Sub Btn_Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Search.Click

        If Ch_B_Name.Checked = True And Ch_B_Date.Checked = False Then

            Dim dt As DataTable
            dt = GetTable("SELECT * FROM BatchFinal WHERE BatchName='" & C_B_G.Text & "'")
            Semi_Search.DGV_Semi.DataSource = GetTable("SELECT * FROM BatchFinal WHERE BatchName='" & C_B_G.Text & "'")

            Semi_Search.DGV_Semi.Columns(0).HeaderText = "المسلسل"
            Semi_Search.DGV_Semi.Columns(1).HeaderText = "اسم الخلطة"
            Semi_Search.DGV_Semi.Columns(2).HeaderText = "ذرة 1"
            Semi_Search.DGV_Semi.Columns(3).HeaderText = "ذرة 2"
            Semi_Search.DGV_Semi.Columns(4).HeaderText = "صويا 1"
            Semi_Search.DGV_Semi.Columns(5).HeaderText = "صويا 2"
            Semi_Search.DGV_Semi.Columns(6).HeaderText = "سن"
            Semi_Search.DGV_Semi.Columns(7).HeaderText = "ردة"
            Semi_Search.DGV_Semi.Columns(8).HeaderText = "كون"
            Semi_Search.DGV_Semi.Columns(9).HeaderText = "جيلوتين"
            Semi_Search.DGV_Semi.Columns(10).HeaderText = "زيت"
            Semi_Search.DGV_Semi.Columns(11).HeaderText = "إضافات"
            Semi_Search.DGV_Semi.Columns(12).HeaderText = "إضافى 1"
            Semi_Search.DGV_Semi.Columns(13).HeaderText = "إضافى 2"
            Semi_Search.DGV_Semi.Columns(14).HeaderText = "الوزن الكلى"
            Semi_Search.DGV_Semi.Columns(15).HeaderText = "الوقت"

            Semi_Search.Show()
        ElseIf Ch_B_Date.Checked = True And Ch_B_Name.Checked = False Then

            Dim dt As DataTable
            dt = GetTable("SELECT * FROM BatchFinal WHERE DateTime >= '" & Format(Date_From.Value, "yyyy/MM/dd hh:mm tt") & "' and DateTime <= '" & Format(Date_To.Value, "yyyy/MM/dd hh:mm tt") & "' ")
            Semi_Search.DGV_Semi.DataSource = GetTable("SELECT * FROM BatchFinal WHERE DateTime >= '" & Format(Date_From.Value, "yyyy/MM/dd hh:mm tt") & "' and DateTime <= '" & Format(Date_To.Value, "yyyy/MM/dd hh:mm tt") & "' ")

            Semi_Search.DGV_Semi.Columns(0).HeaderText = "المسلسل"
            Semi_Search.DGV_Semi.Columns(1).HeaderText = "اسم الخلطة"
            Semi_Search.DGV_Semi.Columns(2).HeaderText = "ذرة 1"
            Semi_Search.DGV_Semi.Columns(3).HeaderText = "ذرة 2"
            Semi_Search.DGV_Semi.Columns(4).HeaderText = "صويا 1"
            Semi_Search.DGV_Semi.Columns(5).HeaderText = "صويا 2"
            Semi_Search.DGV_Semi.Columns(6).HeaderText = "سن"
            Semi_Search.DGV_Semi.Columns(7).HeaderText = "ردة"
            Semi_Search.DGV_Semi.Columns(8).HeaderText = "كون"
            Semi_Search.DGV_Semi.Columns(9).HeaderText = "جيلوتين"
            Semi_Search.DGV_Semi.Columns(10).HeaderText = "زيت"
            Semi_Search.DGV_Semi.Columns(11).HeaderText = "إضافات"
            Semi_Search.DGV_Semi.Columns(12).HeaderText = "إضافى 1"
            Semi_Search.DGV_Semi.Columns(13).HeaderText = "إضافى 2"
            Semi_Search.DGV_Semi.Columns(14).HeaderText = "الوزن الكلى"
            Semi_Search.DGV_Semi.Columns(15).HeaderText = "الوقت"

            Semi_Search.Show()

        ElseIf Ch_B_Date.Checked = True And Ch_B_Name.Checked = True Then
            Dim dt As DataTable
            dt = GetTable("SELECT * FROM BatchFinal WHERE BatchName='" & C_B_G.Text & "' and DateTime >= '" & Format(Date_From.Value, "yyyy/MM/dd hh:mm tt") & "' and DateTime <= '" & Format(Date_To.Value, "yyyy/MM/dd hh:mm tt") & "' ")
            Semi_Search.DGV_Semi.DataSource = GetTable("SELECT * FROM BatchFinal WHERE BatchName='" & C_B_G.Text & "' and DateTime >= '" & Format(Date_From.Value, "yyyy/MM/dd hh:mm tt") & "' and DateTime <= '" & Format(Date_To.Value, "yyyy/MM/dd hh:mm tt") & "' ")

            Semi_Search.DGV_Semi.Columns(0).HeaderText = "المسلسل"
            Semi_Search.DGV_Semi.Columns(1).HeaderText = "اسم الخلطة"
            Semi_Search.DGV_Semi.Columns(2).HeaderText = "ذرة 1"
            Semi_Search.DGV_Semi.Columns(3).HeaderText = "ذرة 2"
            Semi_Search.DGV_Semi.Columns(4).HeaderText = "صويا 1"
            Semi_Search.DGV_Semi.Columns(5).HeaderText = "صويا 2"
            Semi_Search.DGV_Semi.Columns(6).HeaderText = "سن"
            Semi_Search.DGV_Semi.Columns(7).HeaderText = "ردة"
            Semi_Search.DGV_Semi.Columns(8).HeaderText = "كون"
            Semi_Search.DGV_Semi.Columns(9).HeaderText = "جيلوتين"
            Semi_Search.DGV_Semi.Columns(10).HeaderText = "زيت"
            Semi_Search.DGV_Semi.Columns(11).HeaderText = "إضافات"
            Semi_Search.DGV_Semi.Columns(12).HeaderText = "إضافى 1"
            Semi_Search.DGV_Semi.Columns(13).HeaderText = "إضافى 2"
            Semi_Search.DGV_Semi.Columns(14).HeaderText = "الوزن الكلى"
            Semi_Search.DGV_Semi.Columns(15).HeaderText = "الوقت"
            Semi_Search.Show()

        End If
        

    End Sub

    Private Sub reports_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim dt As DataTable
        dt = GetTable("SELECT * FROM vwBatchs")
        Dim n As Integer = dt.Rows.Count
        For i As Integer = 0 To n - 1
            C_B_G.Items.Add(dt.Rows(i).Item(0))
        Next
    End Sub
End Class